class RedstoneRenderer : public IBlockRenderer
{
public:
	ITexture *Texture;

	RedstoneRenderer(ITexture *texture) :
		Texture(texture)
	{
	}

	int GetTypeData(const int &data) { return data; }

	void Render(Schematic *schematic, RendererBase *renderer, const Block &block, const Point3i &position)
	{
		auto &north = schematic->GetBlock(position.X, position.Y, position.Z + 1);
		auto &south = schematic->GetBlock(position.X, position.Y, position.Z - 1);
		auto &east = schematic->GetBlock(position.X + 1, position.Y, position.Z);
		auto &west = schematic->GetBlock(position.X - 1, position.Y, position.Z);

		bool connectedNorth = (north != Block::Empty && north.ID == block.ID);
		bool connectedSouth = (south != Block::Empty && south.ID == block.ID);
		bool connectedEast = (east != Block::Empty && east.ID == block.ID);
		bool connectedWest = (west != Block::Empty && west.ID == block.ID);

		if (!connectedNorth && !connectedSouth && !connectedEast && !connectedWest)
			renderer->Draw(Face(Point3f(5, 15, 5), Point3f(11, 15, 5), Point3f(11, 15, 11), Point3f(5, 15, 11), Colorb(129, 8, 10, 255), Texture, Point2i(4 * 16 + 5, 10 * 16 + 5), 6, 6));
		else
		{
			if (connectedNorth && connectedSouth && connectedEast && connectedWest)
				renderer->Draw(Face(Point3f(0, 15, 0), Point3f(16, 15, 0), Point3f(16, 15, 16), Point3f(0, 15, 16), Colorb(129, 8, 10, 255), Texture, Point2i(4 * 16, 10 * 16), 16, 16));
			else if (connectedNorth && connectedWest && connectedEast)
				renderer->Draw(Face(Point3f(0, 15, 5), Point3f(16, 15, 5), Point3f(16, 15, 16), Point3f(0, 15, 16), Colorb(129, 8, 10, 255), Texture, Point2i(4 * 16, 10 * 16 + 5), 16, 11));
			else if (connectedSouth && connectedWest && connectedEast)
				renderer->Draw(Face(Point3f(0, 15, 0), Point3f(16, 15, 0), Point3f(16, 15, 11), Point3f(0, 15, 11), Colorb(129, 8, 10, 255), Texture, Point2i(4 * 16, 10 * 16), 16, 11));
			else if (connectedEast && connectedNorth && connectedSouth)
				renderer->Draw(Face(Point3f(5, 15, 0), Point3f(16, 15, 0), Point3f(16, 15, 16), Point3f(5, 15, 16), Colorb(129, 8, 10, 255), Texture, Point2i(4 * 16 + 5, 10 * 16), 11, 16));
			else if (connectedWest && connectedNorth && connectedSouth)
				renderer->Draw(Face(Point3f(0, 15, 0), Point3f(11, 15, 0), Point3f(11, 15, 16), Point3f(0, 15, 16), Colorb(129, 8, 10, 255), Texture, Point2i(4 * 16, 10 * 16), 11, 16));
			else if (connectedNorth && connectedWest)
				renderer->Draw(Face(Point3f(0, 15, 5), Point3f(11, 15, 5), Point3f(11, 15, 16), Point3f(0, 15, 16), Colorb(129, 8, 10, 255), Texture, Point2i(4 * 16, 10 * 16 + 5), 11, 11));
			else if (connectedNorth && connectedEast)
				renderer->Draw(Face(Point3f(5, 15, 5), Point3f(16, 15, 5), Point3f(16, 15, 16), Point3f(5, 15, 16), Colorb(129, 8, 10, 255), Texture, Point2i(4 * 16 + 5, 10 * 16 + 5), 11, 11));
			else if (connectedSouth && connectedEast)
				renderer->Draw(Face(Point3f(5, 15, 0), Point3f(16, 15, 0), Point3f(16, 15, 11), Point3f(5, 15, 11), Colorb(129, 8, 10, 255), Texture, Point2i(4 * 16 + 5, 10 * 16), 11, 11));
			else if (connectedSouth && connectedWest)
				renderer->Draw(Face(Point3f(0, 15, 0), Point3f(11, 15, 0), Point3f(11, 15, 11), Point3f(0, 15, 11), Colorb(129, 8, 10, 255), Texture, Point2i(4 * 16, 10 * 16), 11, 11));
			else if (connectedEast || connectedWest)
				renderer->Draw(Face(Point3f(0, 15, 0), Point3f(16, 15, 0), Point3f(16, 15, 16), Point3f(0, 15, 16), Colorb(129, 8, 10, 255), Texture, Point2i(5 * 16, 10 * 16), 16, 16));
			else if (connectedNorth || connectedSouth)
				renderer->Draw(Face(Point3f(0, 15, 16), Point3f(0, 15, 0), Point3f(16, 15, 0), Point3f(16, 15, 16), Colorb(129, 8, 10, 255), Texture, Point2i(5 * 16 + 16, 10 * 16), -16, 16));
		}
	}
};